/**
 * 详情对话框
 */
var BasicPositionInfoDlg = {
    data: {
        positionAreaId: "",
        positionAreaName: "",
        positionName: "",
        positionNumber: "",
        positionType: "",
        positionFunction: "",
        positionCondition: "",
        positionAreaType: "",
        positionFloor: "",
        positionLine: "",
        positionColumn: "",
        positionLayer: "",
        positionLength: "",
        positionWidth: "",
        positionHeight: "",
        positionWeight: "",
        positionBarcode: "",
        positionProduct: "",
        positionMeasure: "",
        positionProducttype: "",
        positionPutorder: "",
        positionPickingorder: "",
        positionAvailable: "",
        positionAlready: "",
        positionState: "",
        positionNotes: "",
        version: "",
        deliverId: "",
        createTime: "",
        updateTime: "",
        createUser: "",
        updateUser: ""
    }
};

/**
 * 添加或者修改页面
 */
var OrderPutDetailedInfoDlg = {
    data: {
        detailedGoodsname: "",
        detailedGoodsnum: "",
        goodsNumber: "",
		goodsNo:"",

        detailedRebubbles: "",
        detailedPacking: "",
        detailedLargeclass: "",
        detailedGoodstype: "",
        detailedPutcondition: "",
        detailedPiecenum: "",
        goodsUnit: "",
        goodsSpecs: "",

        goodsWeight: "",
        goodsVolume: "",
        goodsCharging: ""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/basicPosition/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('basicPositionForm', result.data);

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/basicPosition/editItem", function (data) {
            Feng.success("更新成功！");
            window.location.href = Feng.ctxPath + '/basicPosition'
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/basicPosition'
    });
    
    //查询库区
    form.on('select(warehouseId)',function(){
    	$("#positionAreaId").empty();
    	$.ajax({
    		url:Feng.ctxPath + '/basicArea/queryArea',
    	    dataType:"json",   //返回格式为json
    	    async: false,
    	    data:{"areaWarehouseId":$("#warehouseId").val()},    //参数值
    	    type:"post",   //请求方式
    	    success:function(data){
    	        if(data.length>0){
    	        	var str = "<option value=''>请选择</option>";
    	        	$.each(data,function(key,value){
    	        		str += "<option value='"+value.id+"'>"+value.areaName+","+value.areaNumber+"</option>";
    	        	});
    	        	$("#positionAreaId").html(str);
    	        }
    	    }
    	});
        form.render('select');
    });
    
});